/**
 * 
 */
package unit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import operands.Operand;
import operators.Operator;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * @author NextEpisode1
 *
 */
public class OperatorTest{
	private Operator operatorObject;
	
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		operatorObject = new Operator("+");
		operatorObject.setLeft(new Operand("1"));
		operatorObject.setRight(new Operand("2"));
		assertNotNull(operatorObject);
	}

	/**
	 * Test method for {@link operators.Operator#computeDerivate()}.
	 */
	@Test
	public void testComputeDerivate() {	
		assertEquals(new Double(0), operatorObject.computeDerivate());
	}

	/**
	 * Test method for {@link operators.Operator#evalDerivate()}.
	 */
	@Test
	public void testEvalDerivate() {
		assertEquals("0+0", operatorObject.evalDerivate());
	}

	/**
	 * Test method for {@link operators.Operator#compute()}.
	 */
	@Test
	public void testCompute() {	
		assertTrue(operatorObject.getRight().getContent()=="2");
		assertEquals((Double)3.0, (Double)operatorObject.compute());
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
		operatorObject = null;
	}
}
